package com.codemonkey.lq.qd.facotry.config;

public abstract class AbstractFlowDefinition implements FlowDefinition {

	private String from;

	private String to;

	private String condition;

	@Override
	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	@Override
	public String getTo() {
		return to;
	}

	public void setTo(String to) {
		this.to = to;
	}

	@Override
	public String getCondition() {
		return condition;
	}

	public void setCondition(String condition) {
		this.condition = condition;
	}

	@Override
	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}

		if (other == null || other.getClass() != this.getClass()) {
			return false;
		}

		AbstractFlowDefinition that = (AbstractFlowDefinition) other;


		// 三个同时相等
		return (this.from.equalsIgnoreCase(that.from) &&
				this.to.equalsIgnoreCase(that.to) &&
				this.condition.equalsIgnoreCase(that.condition));
	}

	@Override
	public int hashCode() {
		return String.format("%s#%s#%s#%s", this.getClass().getName(), this.from, this.to,
				this.condition).hashCode();
	}

	@Override
	public String toString() {
		return String.format("['%s' -> '%s']+'%s'", from, to, condition);
	}

}
